from rest_framework.decorators import api_view
from rest_framework.response import Response
from file.serializers import FileSerializer


@api_view(["POST"])
def upload(request):
    """
    上传文件
    :param request:
    :return:
    """
    if request.method == "POST":
        serializer = FileSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        serializer.save()
        return Response(data=serializer.data, status=200)